//跨组件共享的数字数据
import { create } from "zustand";
import { persist } from "zustand/middleware";
interface CounterType {
  count: number;
  increment: () => void;
}
export const useCounter = create<CounterType>()(
  persist(
    (set) => ({
      count: 10, //数据包
      increment: () => {
        set((state) => ({ count: state.count + 1 }));
      },
    }),
    {
      name: "my-count", //开启持久化存储，数据本地存储的名称
    }
  )
);
